package redis

import (
	"context"
	"fmt"
)

const GoodsStock = "cart:goods_id_"

func GoodsStocks(goodsId int64, stock int64) {
	key := GoodsStock + fmt.Sprintf("%d", goodsId)
	for i := 0; i < int(stock); i++ {
		Client.LPush(context.Background(), key, goodsId)
	}
}
func Stock(goodsId int64) int64 {
	key := GoodsStock + fmt.Sprintf("%d", goodsId)
	return Client.LLen(context.Background(), key).Val()
}
